 //======================================================================
//    We will gone,the word kept
//======================================================================
//    version & features log
//======================================================================
 module fifo_axis
  #(parameter DW = 16,
   parameter AW = 10,
   parameter UW = 4 ,
   parameter PROG_EMPTY = 4,
   parameter PROG_FULL = 2**AW-128,
   parameter ASY_CLK_ENB = "TRUE")
 (
 input          m_aclk                 ,                       
 input          s_aclk                 ,  
 input          s_aresetn              ,      
 input          s_axis_tvalid          ,          
 output         s_axis_tready          ,          
 input [DW-1:0] s_axis_tdata           ,          
 input          s_axis_tlast           ,          
 input [UW-1:0] s_axis_tuser           ,          
 output          m_axis_tvalid          ,          
 input           m_axis_tready         ,          
 output [DW-1:0] m_axis_tdata          ,          
 output          m_axis_tlast          ,          
 output [UW-1:0] m_axis_tuser          , 
 output          axis_almost_full       ,
 output          axis_almost_empty      ,         
 output [AW : 0] axis_wr_data_count    ,                  
 output [AW : 0] axis_rd_data_count
 );
wire  rst           ;
wire  wr_en         ;
wire  rd_en         ;    
wire  fifo_rd_en    ;    
wire  fifo_empty    ; 
 
assign rst   = ~s_aresetn;
assign rd_en = m_axis_tready ;//2024.03.29 & m_axis_tvalid ;
assign wr_en = s_axis_tready ;//2024.03.29 & s_axis_tvalid ;

//
wire[DW+UW:0]    fifo_dout ; 
wire[DW+UW:0]    fifo_din  ; 
wire[DW+UW:0]    fwft_dout ;
assign fifo_din = { s_axis_tlast,s_axis_tuser,s_axis_tdata};
assign m_axis_tlast = fwft_dout[DW+UW];
assign m_axis_tuser = fwft_dout[(DW+UW-1)-:UW];
assign m_axis_tdata = fwft_dout[DW-1:0];
  fifo_fwft_adapter #(
    .DATA_WIDTH (DW+UW+1   )
  ) fwft_adapter (
    .clk          (m_aclk),
    .rst          (rst ),
    .rd_en_i      (rd_en),
    .fifo_empty_i (fifo_empty),
    .fifo_rd_en_o (fifo_rd_en),
    .fifo_dout_i  (fifo_dout),
    .dout_o       (fwft_dout),
    .empty_o      (m_axis_tvalid)
  );

//like as native fifo
wire           full    ; 

fifo  
  #( .ADDR_WIDTH      (AW       ),
    .DATA_WIDTH      (DW+UW+1    ),
    .PROG_EMPTY      (PROG_EMPTY ),
    .PROG_FULL       (PROG_FULL  ),
    .ASY_CLK_ENB     (ASY_CLK_ENB)
  )   u_fifo
  ( 
  .wr_rst          (rst    )    ,
  .rd_rst          (rst    )    ,
  .wr_clk          (s_aclk )    ,
  .rd_clk          (m_aclk )    ,
  .din             (fifo_din       ),
  .wr_en           (wr_en          ),
  .rd_en           (fifo_rd_en     ),
  .dout            (fifo_dout      ),
  .full            (full           ),
  .empty           (fifo_empty     ),
  .almost_full     (axis_almost_full ),
  .almost_empty    (axis_almost_empty),
  .rd_data_count   (axis_rd_data_count )    ,
  .wr_data_count   ( axis_wr_data_count)  
 );

assign s_axis_tready = ~full ;

 endmodule

